package com.example.baseapp.adpter

import com.chad.library.adapter.base.BaseSectionQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.example.baseapp.R
import com.example.baseapp.entry.MySecondSection
import com.example.baseapp.entry.ThreeLayerBean

class SecondLayerAdapter(data: MutableList<MySecondSection>) :
    BaseSectionQuickAdapter<MySecondSection, BaseViewHolder>(
        R.layout.second_item_layout, R.layout.second_header_layout, data
    ) {
    override fun convertHead(helper: BaseViewHolder?, item: MySecondSection?) {
        if (item?.header == "同步课"){
            helper?.setBackgroundRes(R.id.imageView,R.mipmap.tianqi1)
        }else{
            helper?.setBackgroundRes(R.id.imageView,R.mipmap.tianqi2)
        }
        helper?.setText(R.id.tv_classType, item?.header)
    }

    override fun convert(helper: BaseViewHolder?, item: MySecondSection?) {
        if (item?.t is ThreeLayerBean.TripleLevelKnowledgeListDTO.DoubleLevelKnowledgeListDTO.SyncClassDTO) {
            val itemBean =
                item.t as ThreeLayerBean.TripleLevelKnowledgeListDTO.DoubleLevelKnowledgeListDTO.SyncClassDTO
            helper?.setText(R.id.tv_knowlege, itemBean.name)
        } else if (item?.t is ThreeLayerBean.TripleLevelKnowledgeListDTO.DoubleLevelKnowledgeListDTO.GoodClassDTO) {
            val itemBean =
                item.t as ThreeLayerBean.TripleLevelKnowledgeListDTO.DoubleLevelKnowledgeListDTO.GoodClassDTO
            helper?.setText(R.id.tv_knowlege, itemBean.name)
        }

    }
}